package com.mynameisguillaume.utils.context 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.system.ApplicationDomain;
	/**
	 * ...
	 * @author guibar
	 */
	public class ContextUtils 
	{
		public static function getMovieClip(pName : String) : MovieClip
		{
			if (ApplicationDomain.currentDomain.hasDefinition(pName))
			{
				var c : Class = ApplicationDomain.currentDomain.getDefinition(pName) as Class;
				var mc : MovieClip = new c();
				return mc;
			}
			else
			{
				return null;
			}
		}
		public static function getBitmapData(pName : String) : BitmapData
		{
			if (ApplicationDomain.currentDomain.hasDefinition(pName))
			{
				var c : Class = ApplicationDomain.currentDomain.getDefinition(pName) as Class;
				var bmd : BitmapData = new c(0, 0);
				return bmd;
			}
			else
			{
				return null;
			}
		}
		public static function getBitmap(pName : String, pixelSnapping : String = "auto", smoothing : Boolean = true) : Bitmap
		{
			if (ApplicationDomain.currentDomain.hasDefinition(pName))
			{
				var c : Class = ApplicationDomain.currentDomain.getDefinition(pName) as Class;
				var bmd : BitmapData = new c(0, 0);
				var bmp : Bitmap = new Bitmap(bmd, pixelSnapping, smoothing);
				return bmp;
			}
			else
			{
				return null;
			}
		}
	}
}